<template>
  <div>
  <el-form :inline="true" :model="formInline" class="demo-form-inline">
    <el-form-item label="仓库名称">
      <el-input v-model="formInline.sName" placeholder="仓库名称"></el-input>
    </el-form-item>
    <el-form-item label="关键词">
      <el-input v-model="formInline.sDesc" placeholder="关键词描述"></el-input>
    </el-form-item>
    <el-form-item>
      <el-button type="primary" @click="onSubmit">查询</el-button>
    </el-form-item>
  </el-form>


  <el-table
    :data="tableData"
    border
    style="width: 100%">
    <el-table-column
      fixed
      prop="sId"
      label="序号"
      >
    </el-table-column>
    <el-table-column
      prop="sName"
      label="仓库名称"
      >
    </el-table-column>
    <el-table-column
      prop="sAddress"
      label="地址"
      >
    </el-table-column>
    <el-table-column
      prop="sDesc"
      label="描述">
    </el-table-column>
    <el-table-column
      fixed="right"
      label="操作"
      >
      <template slot-scope="scope">
        <el-button @click="handleClick(scope.row)" type="text" size="small">查看</el-button>
        <el-button type="text" size="small">编辑</el-button>
      </template>
    </el-table-column>
  </el-table>


  <el-pagination
    background
    layout="prev, pager, next"
    :total="page.total"
    :page-size="2"
    @current-change="pageMethod"
  >
  </el-pagination>

  </div>

</template>

<script>
export default {
  name: "StashList",

  data(){
    return{
      page:{
        total:0
      },


      formInline: {
        sName: '',
        sDesc: ''
      },

      tableData: []
    }
  },
  mounted() {

    var vm = this

    this.axios({
      method:"GET",
      url:"/api/store/findAll?pageNum=1&pageSize=2"
    }).then(function (res){
      if(res.data.code == 200){

        console.log(res.data.data)

        vm.tableData = res.data.data.list
        vm.page.total = res.data.data.total

      }
    })

  },

  methods: {
    handleClick(row) {
      console.log(row);
    },

    onSubmit(){

      var vm = this

      this.axios({
        method:"GET",
        url:"/api/store/findAll?sName="+vm.formInline.sName+"&sDesc="+vm.formInline.sDesc+"&pageNum=1&pageSize=2"
      }).then(function (res){
        if(res.data.code == 200){

          console.log(res.data.data)

          vm.tableData = res.data.data.list
          vm.page.total = res.data.data.total

        }
      })

    },

    pageMethod(pageNum){

      var vm = this

      this.axios({
        method:"GET",
        url:"/api/store/findAll?name="+vm.formInline.name+"&code="+vm.formInline.code+"&pageNum="+pageNum+"&pageSize=2"
      }).then(function (res){
        if(res.data.code == 200){

          console.log(res.data.data)

          vm.tableData = res.data.data.list

          vm.page.total = res.data.data.total

        }
      })


    }
  }
}
</script>

<style scoped>

</style>
